#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
long long x[maxn], y[maxn], c[maxn], l[maxn], r[maxn];
vector<long long> alls;
long long res[maxn*3];
int R;
int n, m, len;
int indexOf(int val) {
  int l=0, r=alls.size();
  while(l+1<r) {
    int mid = (l+r)/2;
    if(alls[mid]<=val) l = mid;
    else r = mid;
    // cout<<mid<<endl;
  }
  return l;
}
int main() {
  cin>>n>>m;
  alls.push_back(-2e9);
  for(int i=1; i<=n; ++i) {cin>>x[i]>>c[i];alls.push_back(x[i]);}
  for(int i=1; i<=m; ++i) {cin>>l[i]>>r[i];alls.push_back(l[i]);alls.push_back(r[i]);}
  sort(alls.begin(), alls.end());
  alls.erase(unique(alls.begin(), alls.end()), alls.end());

  for(int i=1; i<=n; ++i) {
    res[indexOf(x[i])] += c[i];
  }
  for(int i=1; i<=alls.size(); ++i) res[i] += res[i-1];

  for(int i=1; i<=m; ++i) {
    cout<<res[indexOf(r[i])] - res[indexOf(l[i])-1]<<'\n';
  }
}
